/*
 *  $Id: Spell.cs 925 2009-12-02 12:50:02Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using AgateLib.DisplayLib;

namespace Ragima {
    /// <summary>
    /// Абстрактный эффект, связанный с конкретной картой и берущий ее данные
    /// </summary>
    public abstract class SpellAffect: GroupAffect {
        private static readonly Languages.Phrase CapName = new Languages.Phrase("affect.spell");

        private bool _default;
        public bool DefaultName;
        public bool DefaultDescription;

        public SpellAffect(): this(false) {}
        public SpellAffect(bool def) {
            _default = def;
            DefaultName = false;
            DefaultDescription = false;
        }

        public abstract Card BaseCard { get; }

        public override Languages.Phrase Name {
            get { return DefaultName ? base.Name : CapName; }
        }
        public override string NameText {
            get { return DefaultName ? base.NameText : Name.GetText(BaseCard); }
        }

        public override ElementType Element {
            get { return BaseCard.Element; }
        }
        public override Languages.Phrase Description {
            get { return DefaultDescription ? base.Description : BaseCard.Description; }
        }
        public override string DescriptionText {
            get { return DefaultDescription ? base.DescriptionText : BaseCard.DescriptionText; }
        }

        public override Surface BigPicture {
            get { return BaseCard.BigPicture; }
        }

        public override Surface SmallPicture {
            get { return BaseCard.SmallPicture; }
        }

        public override bool DrawHelp(int x, int y) {
            if (_default)
                return DrawHelpDefault(x, y);
            else
                return BaseCard.DrawHelp(x, y);
        }
    }

    /// <summary>
    /// Абстрактный эффект, связанный с конкретной картой и берущий ее данные
    /// Определяет карту по генерик-параметру
    /// </summary>
    public abstract class SpellAffect<T>: SpellAffect where T: Card {
        private T _card;

        public SpellAffect(): base() { }
        public SpellAffect(bool def): base(def) { }

        public override string Id {
            get { return AffectManager.GetCardId<T>(null); }
        }
        public T Card {
            get { return _card ?? (_card = CardManager.GetCard<T>()); }
        }
        public override Card BaseCard {
            get { return Card; }
        }
    }
}